﻿using System;
using System.Collections.Generic;


using Microsoft.VisualStudio.TestTools.UnitTesting;

using Utilities;

namespace DataAccess.Tests
{
    [TestClass()]
    public class OdbcDataAccessCommandsTest
    {
        private TestContext testContextInstance;

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //Use ClassInitialize to run code before running the first test in the class
        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
        }
        
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        readonly string connectionName = "OdbcDataAccessTest.ConnectionString";

        public class fUser
        {
            public string Url { get; set; }
        }

        [TestMethod()]
        public void OdbcQueryObjectTest()
        {
            DatabaseResponse<fUser> response = Factory
                .Command()
                .Connection(connectionName)
                .Text("SELECT URL FROM URL WHERE Type=?")
                .Parameter("type", "PRD", 10)
                .QueryObject<fUser>((reader, msg) =>
                {
                    msg.Url = reader.GetString(0);
                });

            fUser user = response.Data;

            Assert.AreEqual("some value", user.Url); 
        }

    }
}
